<?php
namespace Admin\Controller;

use Frame\Libs\BaseController;
use Admin\Model\UserLogModel;
use Frame\Frame;

final class UserLogController extends BaseController{
	public function index(){
		$this->denyAccess();
		//分页参数
		$where = "2>1";
		if(!empty($_REQUEST["add_time"])) $where .= " AND add_time LIKE '%".$_REQUEST["add_time"]."%'";

		$page = isset($_GET["page"]) ? $_GET["page"] : 1;
		$pageSize = 10;
		$startPage = ($page-1)*$pageSize;
		$records = UserLogModel::getInstance()->rowCount($where);
		$url = [
			"c" => CONTROLLER,
			"a" => ACTION,
		];
		//添加链接地址
		if(!empty($_REQUEST["add_time"])) $params["add_time"] = $_REQUEST["add_time"];
		
		$pageStr = new \Frame\Vendor\Pager($records,$pageSize,$page,$url);
		$pageStr = $pageStr->showPage();
		
		$data = UserLogModel::getInstance()->UserLog($where,$startPage,$pageSize);
		foreach ($data as $key=>$value){
			$data[$key]["add_time"] = date("Y-m-d H:i:s",$value["add_time"]);
		}
		$this->smarty->assign([
				"data" 	  => $data,
				"pageStr" => $pageStr,
		]);
		$this->smarty->display("Log/user_log.html");
	}
}